package com.micro.frog.common.base;


import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页结果
 *
 * @author :  ljh
 * @date : 2018/4/4
 **/
@Data
public class PageRes<T> implements Serializable {

    /**
     * 页码
     */
    private Long pageNum;

    /**
     * 每页条数
     */
    private Long pageSize;

    /**
     * 总条数
     */
    private Long total;

    /**
     * 数据
     */
    private List<T> data;

    public PageRes() {
    }

    public PageRes(Long pageNum, Long pageSize, Long total, List<T> data) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.total = total;
        this.data = data;
    }

    private PageRes(Long total, List<T> data) {
        this.total = total;
        this.data = data;
    }

    public static <T> PageRes<T> success(Long pageNum, Long pageSize, Long total, List<T> data) {
        return new PageRes<>(pageNum, pageSize, total, data);
    }

    public static <T> PageRes<T> success(Long total, List<T> data) {
        return new PageRes<>(total, data);
    }

    public static <T> PageRes<T> success(List<T> data) {
        return success(0L, data);
    }

    public static <T> PageRes<T> success() {
        return new PageRes<>();
    }

}
